/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.repair.mapper;

import org.apache.ibatis.annotations.Param;
import org.springblade.modules.repair.dto.BuildingSelectSearchDTO;
import org.springblade.modules.repair.entity.Building;
import org.springblade.modules.repair.vo.*;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.repair.vo.rescue.MapRescueBuildingDetailVO;
import org.springblade.modules.repair.vo.statistics.BrandStatisticsListVO;
import org.springblade.modules.repair.vo.statistics.BuildingStatisticsListVO;
import org.springblade.modules.repair.vo.statistics.ElevatorStatisticsListVO;

import java.util.List;

/**
 * 楼盘信息 Mapper 接口
 *
 * @author BladeX
 * @since 2021-05-21
 */
public interface BuildingMapper extends BaseMapper<Building> {

	/**
	 * 自定义分页
	 *
	 * @param page
	 * @param building
	 * @return
	 */
	List<BuildingVO> selectBuildingPage(IPage page, BuildingVO building);

    List<ListBuildingVO> listBuilding(@Param("buildingName") String buildingName);

//	/**
//	 * 我维保的小区
//	 * @return
//	 */
//	List<BuildingSelectVO> myMaintainBuilding(IPage page,@Param("search") BuildingSelectSearchDTO search, @Param("userId") Long userId);

	BuildingSubmitVO buildingSubmitVOR(@Param("buildingId") Long buildingId);

	/**
	 * 维保小区列表
	 * @param page
	 * @param search
	 * @return
	 */
	List<BuildingSelectVO> myMaintainBuildingList(IPage page,@Param("search") BuildingSelectSearchDTO search);

	/**
	 * 维保小区电梯列表
	 * @param search
	 */
	List<ElevatorSelectVO> myMaintainBuildingChild(@Param("search") BuildingSelectSearchDTO search);

	/**
	 * 维保小区统计
	 * @param search
	 * @return
	 */
	List<BuildingSelectVO> myElevatorStatistics(@Param("search") BuildingSelectSearchDTO search);

	/**
	 * 项目统计列表
	 * @param condition 3:已到期, 5即将到期 (对应blade_building_contract_plus表contract_status)
	 * @param userIds
	 * @return
	 */
	List<BuildingStatisticsListVO> buildingStatisticsList(@Param("condition") Integer condition, @Param("userIds") List<Long> userIds);

	/**
	 * 电梯统计列表
	 * @return
	 */
	List<ElevatorStatisticsListVO> elevatorStatisticsList(@Param("userIds") List<Long> userIds);

	/**
	 * 电梯品牌统计列表
	 * @return
	 */
	List<BrandStatisticsListVO> brandStatisticsList(@Param("userIds") List<Long> userIds);

//
//    List<BuildingSelectVO> statisticsZsPlan(@Param("groupIds")List<Long> groupIds);

	/**
	 * 在使用的电梯数量统计
	 * @return
	 */
	Long elevatorCountStatistics();

	/**
	 * 我的电梯-个人管理电梯-小区项目列表
	 * @param userId
	 * @param search
	 * @param page
	 * @return
	 */
	List<PrincipalBuildingListVO> personalBuildingList(@Param("userId") Long userId, @Param("search") BuildingSelectSearchDTO search, IPage page);

	/**
	 * 我的电梯-个人管理电梯-小区项目电梯
	 * @param userId
	 * @param search
	 * @return
	 */
	List<PrincipalElevatorListVO> personalElevatorList(@Param("userId") Long userId, @Param("search") BuildingSelectSearchDTO search);

	/**
	 * 我的电梯-部门管理电梯-小区项目列表
	 * @return
	 */
	List<PrincipalBuildingListVO> deptBuildingList(@Param("search") BuildingSelectSearchDTO search, IPage page);

	/**
	 * 我的电梯-部门管理电梯-小区项目电梯
	 * @param search
	 * @return
	 */
	List<PrincipalElevatorListVO> deptElevatorList(@Param("search") BuildingSelectSearchDTO search);

	/**
	 * 获取项目列表
	 * @param page 分页参数
	 * @param search 搜索条件
	 * @return 项目列表分页信息
	 */
	IPage<BuildingSelectVO> getBuildingList(IPage<BuildingSelectVO> page,BuildingSelectSearchDTO search);

	/**
	 * 获取项目（建筑）缓存所需 VO 列表
	 * @return 缓存所需 VO 列表
	 */
    List<BuildingRedisVO> listForRedisVO();

	/**
	 * 创建救援工单-小区项目列表选择
	 * @param page
	 * @param search
	 * @return
	 */
	IPage<BuildingSelectVO> rescueBuildingList(IPage<BuildingSelectVO> page, @Param("search") BuildingSelectSearchDTO search);

	/**
	 * 创建救援工单-小区项目电梯列表选择
	 * @param page
	 * @param search
	 * @return
	 */
	IPage<ElevatorSelectVO> rescueElevatorList(IPage<ElevatorSelectVO> page, @Param("search") BuildingSelectSearchDTO search);

	MapRescueBuildingDetailVO selectMapRescueBuildingDetail(Long buildingId);
}
